package study.job.elasticjob.job;

import lombok.extern.slf4j.Slf4j;
import org.apache.shardingsphere.elasticjob.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.dataflow.job.DataflowJob;
import org.springframework.stereotype.Component;

import java.util.Arrays;
import java.util.List;

@Slf4j
@Component
public class _2_MyDataflowJob implements DataflowJob<String> {

    @Override
    public List<String> fetchData(ShardingContext context) {
        log.info(">>>>>> fetch data");
        return Arrays.asList("abc", "123");
    }

    @Override
    public void processData(ShardingContext context, List<String> dataLt) {
        log.info(">>>>>> process data");
        dataLt.forEach(e -> {
            log.info(e);
        });
    }

    public static void main(String[] args) throws Exception {
        Process p = Runtime.getRuntime().exec("d:/test.bat");
        int responseCode = p.waitFor();
    }
}
